/**
 * @date 2:47:43 PM
 * EducationSubjectLesson.java
 * Administrator
 * TODO
 */
package com.qs.education.bean.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import lombok.Getter;
import lombok.Setter;

/**
 * @class EducationSubjectLesson
 * @author Warren
 * @description
 * @date Nov 14, 2018
 */
@Entity
@Table(name = "education_subject_lesson")
@Getter
@Setter
public class EducationSubjectLesson {
	@Id
	@Column(name = "id", unique = true, nullable = false)
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	@Column(name = "title", unique = true, nullable = false)
	private String title;
	
	@ManyToOne
	@JoinColumn(name = "unit_id")
	@JsonIgnoreProperties(value = {"subjectLessonList" })
	private EducationSubjectUnit unit;

	@OneToMany
	@JoinColumn(name = "lesson_id")
	@JsonIgnoreProperties(value = { "lesson", "answerList", "homeWorkQuestionList" })
	private List<EducationQuestion> questionList;
	
	@ManyToMany
	@JoinTable(name = "education_homework_lesson", joinColumns = {
			@JoinColumn(name = "lesson_id", referencedColumnName = "id") }, inverseJoinColumns = {
					@JoinColumn(name = "homework_id", referencedColumnName = "id") })
	@JsonIgnoreProperties(value = { "group", "teacher","homeWorkQuestionList","subjectLessonList" })
	private List<EducationHomeWork> homeworkList;
	
	// 新加字段 用来计算课时下 题目的数量
	@Transient
	private Integer numebr;
}
